package com.ywl.lambda;

import java.util.function.Function;
import java.util.function.IntPredicate;

/**
 * lambda练习四
 * @author 24040
 * @name LambdaDemo01
 * @date 2022-08-21 16:30
 */
public class LambdaDemo04 {

    public static void main(String[] args) {
        //匿名内部类
        /*Integer result = typeConver(new Function<String, Integer>() {
            @Override
            public Integer apply(String s) {
                //valueOf 返回的是一个Integer类型
                return Integer.valueOf(s);
            }
        });*/

        //Lambda表达式
        Integer result = typeConver(s-> Integer.valueOf(s));

        typeConver(s ->s.concat("ywl"));
    }

    public static <R> R typeConver(Function<String,R> function){
        String str = "1235";
        R result = function.apply(str);
        System.out.println(result);
        return result;
    }

}
